
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>查询会员信息</title>
	<link rel="stylesheet" type="text/css" href="../css/index.css"/>
<style type="text/css">

</style>
</head>
<body>
	<div class="wrapper">
		<h1>查询会员信息</h1>
		<p style="text-align: center;">查询到的信息如下:</p>
		<div class="add">
			
		</div>
		<table width="100%" border="1" class ="gridtable">
			<tr>
				<th>ID</th>
				<th>姓名</th>
				<th>性别</th>
				<th>年龄</th>
				<th>电话</th>
				<th>住址</th>
				<th>会员码</th>
				<th>出生日期</th>
				<th>会员简介</th>
				<th>操作</th>
			</tr>
			<?php
			define("HOST","localhost");  
			//用户名
			define("USER","root");  
			//密码
			define("PASS","root");
			// 连接mysql
			$link = new mysqli(HOST,USER,PASS);
			$link->query("set names 'utf8'");
			  //选择数据库test
		      mysqli_select_db($link,"test");

                $name_num = $_POST['name_num'];
				// 从test中查询到members数据表，返回数据库结果集,并按照id降序排列  
				// $sql = 'select * from members order by id asc';
				$sql = "select * from members where name='$name_num' or membernum='$name_num'";
				// 结果集
				$result = $link->query($sql);
				if (!$result) {
					printf("Error: %s\n", mysqli_error($link));
					exit();
				}
				// 解析结果集,$row为新闻所有数据，$newsNum为新闻数目
				$newsNum=mysqli_num_rows($result); 
				//循环输出表中的内容 
				for($i=0; $i<$newsNum; $i++){
					$row = mysqli_fetch_assoc($result);
					echo "<tr>";
					echo "<td>{$row['id']}</td>";
					echo "<td>{$row['name']}</td>";
					echo "<td>{$row['gender']}</td>";
					echo "<td>{$row['age']}</td>";
					echo "<td>{$row['phone']}</td>";
					echo "<td>{$row['address']}</td>";
					echo "<td>{$row['membernum']}</td>";
					echo "<td>{$row['birth']}</td>";
					echo "<td>{$row['introduction']}</td>";
					echo "<td>
							<a href='javascript:del({$row['id']})'><div class='div_d'>删除</div></a>
							<a href='edit.php?id={$row['id']}'><div class='div_u'>修改</div></a>
						  </td>";
					echo "</tr>";
				}
				// 释放结果集
				mysqli_free_result($result);
				mysqli_close($link);
			?>
		</table>
	</div>
	<script type="text/javascript">
		function del (id) {
			if (confirm("确定删除这条新闻吗？")){
				window.location = "action-del.php?id="+id;
			}
		}
	</script>
</body>
</html>
